#include<bits/stdc++.h>
using namespace std;
int a[105],n,color[105],ans;
void dfs(int pos)
{
	if(pos==n+1)
	{
		int score=0;
		for(int i=1;i<=n;i++)
		{
			bool flag=0;
			for(int j=i-1;j>=1;j--) 
			{
				if(color[j]==color[i])
				{
					if(a[i]==a[j]) flag=1;
					break;
				}
			}
			if(flag) score+=a[i];
		}
		ans=max(ans,score);
		return ;
	}
	color[pos]=1;
	dfs(pos+1);
	color[pos]=2;
	dfs(pos+1);
}
int main()
{
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	int t;
	cin>>t;
	while(t--)
	{
		ans=0;
		memset(color,0,sizeof(color));
		cin>>n;
		for(int i=1;i<=n;i++) cin>>a[i];
		dfs(1);
		cout<<ans<<endl;
	}
	return 0;
}
